Learn With Nathan

Max Tokens in AI Language Models

"Max tokens" is a parameter used in AI language models (such as GPT-3, GPT-4, Claude, Gemini, etc.) to control the maximum length of the generated output or the total amount of text (input + output) the model can process in a single interaction.

What Are Tokens?

Tokens are the basic units of text that language models use to process and generate language. A token can be as short as one character or as long as one word, depending on the language and the tokenizer. (See the Tokenization section for more details.)

What Does Max Tokens Do?

Why Is Max Tokens Important?

Example

Prompt Max Tokens Example Output
Write a summary of World War II. 20 A brief summary, possibly cut off mid-sentence.
Write a summary of World War II. 100 A more detailed, complete summary.

Practical Tips


Understanding and setting the "max tokens" parameter helps you control the length, cost, and quality of AI-generated content.